<?php
/**
 * ExtWindowBase class file
 *
 * @author TrueSoftware B.V. (The Netherlands)
 * @link http://www.ext4yii.com
 * @copyright Copyright 2007-2010 TrueSoftwareB.V. all rights reserved.
 * @license http://www.ext4yii.com/license/
 *          EVALUATION VERSION - NOT FOR COMMERCIAL USE OR DISTRIBUTION.
 * @version 0.7.2
 */
 
class ExtWindowBase extends ExtPanel
{
    public function parseNode(ExtHTMLParserNode $node,
            ExtASTWalker $astwalker)
    {
        $this->setWindowControl($node);
        parent::parseNode($node, $astwalker);
    }

    private function setWindowControl($root)
    {
        foreach($root->children as $node)
        {
            $this->setWindowControl($node);
            if(!is_null($node->extctl) && !($node->extctl instanceof ExtContainerLayout) )
            {
                $node->extctl->setJavaScriptConfig('getWindow','function(){return Ext.getCmp("'.$this->getId().'"); }');
            }
        }
    }

    public function renderConfig($asobject=true)
    {
        $script = sprintf('Ext.getCmp("%s").on("beforeshow",function(sender){ if(this._ext4yii_init_shown == null) {this._ext4yii_init_shown = true ; sender.alignTo(Ext.getBody(),"c-c");} })',
            $this->getId());
        $this->getController()->addAfterInitScript($script);
        return parent::renderConfig($asobject);
    }
}
?>
